/***************************************************************************
 创建者：华磊
 开始时间：         : 2017.02.13
 copyright            : (C) 深圳市华友高科有限公司
 修改说明：（每次有修改就添加一条，带有 修改人，修改时间，修改描述）

 ***************************************************************************
 *   码垛指令视窗
*                                                                         *
 ***************************************************************************/
#include "palletinstructionview.h"
#include "ui_palletinstructionview.h"
#include "../../programView/programview.h"


PalletInstructionView::PalletInstructionView(int styleId,QWidget *parent) :
    QWidget(parent),
    ui(new Ui::PalletInstructionView)
{
    ui->setupUi(this);
    initialDisplayStyle(styleId);


    palletMotionInstructionView = new PalletMotionInstructionView(styleId,this);
    palletMotionInstructionView->palletInstructionView = this;


    intervalOnPicture = "border-width:0px;border-style:outset;"
                                               "image:url(/agvwork/AgvHmi/baseBag/hmiProject/resources/instruction/PalletInstructionRes/moveON.png);";
    intervalOffPicture = "border-width:0px;border-style:outset;"
                                                "image:url(/agvwork/AgvHmi/baseBag/hmiProject/resources/instruction/PalletInstructionRes/moveOFF.png);";

    rowColumnLayer.resize(3);//行列层
    rowColumnLayer[0] = 1;
    rowColumnLayer[1] = 1;
    rowColumnLayer[2] = 1;
}

void PalletInstructionView::initialDisplayStyle(int styleId)
{
    switch (styleId) {
    case 1:
        ui->save_Btn->setGeometry(360,350,70,40);
        break;
    default:
        break;
    }
}

void PalletInstructionView::getInput()
{
    palIns.stackNumber=ui->palletMode_comboBox->currentIndex()+1;
    palIns.comment=ui->note_lineEdit->text();
    palIns.isStartSet=1;
}

PalletInstructionView::~PalletInstructionView()
{
    delete ui;
}

void PalletInstructionView::updateView()
{
    ui->palletMode_comboBox->setCurrentIndex(palIns.stackNumber-1);
    ui->note_lineEdit->setText(palIns.comment);
}




void PalletInstructionView::on_save_Btn_clicked()
{
    emit finishHeadInstruction();
    emit saveInstruction(palletHeadInstruction);
}

void PalletInstructionView::changeLanguage(int language)
{
    if(1 == language)
    {
        translator.load("/agvwork/AgvHmi/baseBag/hmiProject/language/palletViewEnglishLan.qm");
        qApp->installTranslator(&translator);
    }
    else
    {
        qApp->removeTranslator(&translator);
    }
    ui->retranslateUi(this);


    palletMotionInstructionView->changeLanguage();

}



void PalletInstructionView::on_clearNote_Btn_clicked()
{
    ui->note_lineEdit->clear();
}
